package org.epidroid.epidroid.androsoul.ui.configuration;

import org.epidroid.epidroid.androsoul.engine.service.IAndroSoulService;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class ConfigurationUpdater {

	public static void process(IAndroSoulService _service, Context context) {
		if (_service == null)
			return;

		SharedPreferences prefs = PreferenceManager
				.getDefaultSharedPreferences(context);

		boolean notifs = prefs.getBoolean("enableNotifications", true);
		_service.enableWizz(prefs.getBoolean("enableWizzs", true));
		_service.enableNotifContactLogin(notifs
				&& prefs.getBoolean("notifContactLogin", true));
		_service.enableNotifContactLogoff(notifs
				&& prefs.getBoolean("notifContactLogoff", true));
		_service.enableNotifMessageReceived(notifs
				&& prefs.getBoolean("notifMessageReceived", true));
		
		String loc = prefs.getString("location", "none");
		String comment = prefs.getString("comment", "none");
		_service.setMyComment(comment);
		_service.setMyLocation(loc);

	}
}
